use 	"./output/intermediate/citiesall_patents_age.dta", clear

gen npi_id = master_id if master_id<100
gen cls_id = master_id if master_id>=100
drop pat_wtd_inv

merge m:1 npi_id cls_id f_myr using "./output/cities_expandedpatents" // This merge structure privileges the master!
drop 	_merge

drop 	pat_all_inv-pat_single_inv_wassg
drop 	pat_wtd_inv_noassg pat_wtd_inv_wassg
drop 	prate_*

order 	gen_id city f_myr, first
sort 	gen_id f_myr


compress

save 	"./output/citiesall_patents_age.dta", replace
clear
